{

Some useful procedures and functions

}
unit utils;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, dateutils;


{function DateTimeToUnix(ConvDate: TDateTime): Longint;}
function UnixTime(): int64;
procedure Split (const Delimiter: Char;Input: string; const Strings: TStrings);

implementation

{const
  UnixStartDate: TDateTime = 25569.0;
}
{ Thanks http://www.swissdelphicenter.ch/torry/showcode.php?id=844 }
{function DateTimeToUnix(ConvDate: TDateTime): Longint;
begin
  Result := Round((ConvDate - UnixStartDate) * 86400);
end;
}


function UnixTime(): int64;
begin
  {ctime := Date;}
  {Result := SecondsBetween(EncodeDateTime(2009,MonthOf(ctime),dayof(ctime), hourof(ctime), MinuteOf(ctime),secondof(ctime),MilliSecondOf(ctime)),EncodeDateTime(1970,1,1,0,0,0,0));}
  {Result := SecondsBetween(ctime,EncodeDateTime(1970,1,1,0,0,0,0));}
  {Result := DateTimeToUnix(EncodeDateTime(yearof(ctime),MonthOf(ctime),dayof(ctime), hourof(ctime), MinuteOf(ctime),secondof(ctime),MilliSecondOf(ctime)));}
  Result := DateTimetounix(Now);

end;

procedure Split (const Delimiter: Char; Input: string; const Strings: TStrings) ;
begin
   Assert(Assigned(Strings)) ;
   Strings.Clear;
   Strings.Delimiter := Delimiter;
   Strings.DelimitedText := Input;
end;

end.

